home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / MATH / TP387 / TP387.DOC next >
Encoding:
Text File  |  1991-03-15  |  2.6 KB  |  64 lines

  1.   This program illustrates how floating point performance can be improved
  2. by taking advantage of the 80387/i486 (and non-Intel 287 and 387)
  3. trig functions.  The 8087 and 80287 handled these functions in only the
  4. most primitive way, requiring extensive coding to convert the partial
  5. tangent and partial arctangent instructions into sin, cos, and arctan.
  6.  
  7.   The program consists of several routines to replace the turbo pascal
  8. runtime routines with routines taking advantage of the 387's fsin, fcos,
  9. and fsincos instructions, and the 387's improved implementation of the
  10. fptan and fpatan instructions.
  11.  
  12. ChangeSystemSinCos patches the tp run time routines to use the fsin and
  13. fcos instructions.  This has been tested on TP5.0 and TP6.0.  The change
  14. gives an improvement of about a factor of 4.
  15.  
  16. MySin and MyCos are replacement functions for the TP sin and cos functions,
  17. and do not require the TP run time routines to be patched.  They are somewhat
  18. slower than the patched version.
  19.  
  20. MySinCos is a routine than computes both the sin and the cos of a single
  21. argument.  This is faster than computing the sin and cos independently.
  22.  
  23. Tan is a function than computes the tangent of an argument using the sin
  24. and cos routines.
  25.  
  26. Tan387 computes the tangent using the 387 fptan instruction.
  27.  
  28. Arctan2 computes the arctangent of the quotent of two arguments, setting the
  29. result into the correct quadrant (0 to 2pi) using the TP arctan function.
  30.  
  31. ArcTan387 computes the arctangent of the quotent of two arguments, setting
  32. the result into the correct quadrant (0 to 2pi) using the 387 fpatan
  33. instruction.
  34.  
  35. The rest of the program tests the accuracy of the various routines, and
  36. test the speeds of the routines.  The output of the program produced on
  37. my Northgate 486/25 was:
  38.  
  39. Co-Processor 80387 detected.
  40.  
  41. fsin vs sin     1.110223E-0016
  42. fcos vs cos     1.110223E-0016
  43. fsincos vs sin  1.110223E-0016
  44. fsincos vs cos  1.110223E-0016
  45. arctan2         8.881784E-0016
  46. tan             4.547474E-0013
  47.  
  48.         type     ticks   time/op
  49.   TP sin/cos       138    75.824 usec
  50.       TP tan       148    81.319 usec
  51.  new sin/cos        54    29.670 usec
  52.   my sin/cos        67    36.813 usec
  53.     mysincos        40    21.978 usec
  54.      arctan2        79    43.407 usec
  55.    arctan387        37    20.330 usec
  56.       tan387        31    17.033 usec
  57.  
  58. Joseph R Ahlgren   2218 N Tuckahoe St   Arlington, VA  22205
  59. RBBS  703-241-7980    CompuServe  70461,2340
  60.  
  61. These routines may be freely distributed provided they are unmodified and
  62. include the above attribution.  I would appreciate any comments or
  63. suggestions.
  64.